﻿Imports System.Data.OleDb

Public Class uploadcar1


    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    End Sub

    Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim newfileloc As String
        If fup_Picture.HasFile Then
            newfileloc = Request.MapPath("pictures")
            newfileloc = newfileloc & "/" & fup_Picture.FileName
            fup_Picture.SaveAs(newfileloc)
        Else
            Return
        End If

        Dim conn As New OleDbConnection(ConfigurationManager.ConnectionStrings("CarsConn").ConnectionString)
        Dim sql As String = "INSERT INTO ClassicCars (ModelName,ModelYear,CC,Make,Condition,Color,Registration,Price,ContactNumber,Picture,InfoUrl,SellerPostCode) VALUES (@f1,@f2,@f3,@f4,@f5,@f6,@f7,@f8,@f9,@f10,@f11,@f12)"
        Dim cmd As New OleDbCommand(sql, conn)
        conn.Open()
        cmd.Parameters.AddWithValue("@f1", tb_modelname.Text)
        cmd.Parameters.AddWithValue("@f2", CInt(tb_modelyear.Text))
        cmd.Parameters.AddWithValue("@f3", CInt(tc_cc.Text))
        cmd.Parameters.AddWithValue("@f4", tb_make.Text)
        cmd.Parameters.AddWithValue("@f5", tb_condition.Text)
        cmd.Parameters.AddWithValue("@f6", tb_color.Text)
        cmd.Parameters.AddWithValue("@f7", tb_registration.Text)
        cmd.Parameters.AddWithValue("@f8", CInt(tb_price.Text))
        cmd.Parameters.AddWithValue("@f9", tb_contactnumber.Text)
        cmd.Parameters.AddWithValue("@f10", "pictures/" & fup_Picture.FileName)
        cmd.Parameters.AddWithValue("@f11", tb_infourl.Text)
        cmd.Parameters.AddWithValue("@f12", tb_sellerpostcode.Text)
        cmd.ExecuteNonQuery()
        conn.Close()
        Response.Redirect("Default.aspx")


    End Sub
End Class